﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PRET.ReportControlLib.Controls
{
    public partial class HSMLFilter : UserControl
    {
        public event ShowHSMLReportViewEventHandle showReportEvent;

        public HSMLFilter()
        {
            InitializeComponent();
            InitializeYearsMonths();
        }
        private void InitializeYearsMonths()
        {
            this.dateTimePicker.MaxDate = DateTime.Today;
            this.dateTimePicker.Value = DateTime.Today;
        }

        public void EnableControls(bool sign)
        {
            this.dateTimePicker.Enabled = sign;
            this.reportViewBtn.Enabled = sign;
        }

        private void reportViewBtn_Click(object sender, EventArgs e)
        {
            if (showReportEvent != null)
            {
                ShowHSMLReportViewEventArgs eventArg = new ShowHSMLReportViewEventArgs();
                eventArg.Date = this.dateTimePicker.Value.Date;
                showReportEvent(this, eventArg);
            }
        }
    }

    public delegate void ShowHSMLReportViewEventHandle(object sender, ShowHSMLReportViewEventArgs args);

    public class ShowHSMLReportViewEventArgs : EventArgs
    {
        public ShowHSMLReportViewEventArgs()
        { }
        private DateTime date;

        public DateTime Date
        {
            get { return date; }
            set { date = value; }
        }
    }
}